<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增DW查询配置')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-param-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">分类：</label>
                <div class="col-sm-8">
                    <select name="sdDwtbClass" class="form-control m-b" th:with="type=${@baseSd.getItem('dw_query_param_class')}">
                        <option th:each="item : ${type}" th:text="${item.na}" th:value="${item.cd}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">表名：</label>
                <div class="col-sm-8">
                    <select name="cdDwTb" class="form-control m-b" th:with="type=${@mdMedTbService.selectMdMedTbBySdTbca('')}" onchange="dwTbChange(this)">
                        <option th:each="item : ${type}" th:text="${item.na}" th:value="${item.cd}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">字段集合：</label>
                <div class="col-sm-8">
                    <select class="form-control select2-multiple" name="fldList" multiple id="fieldSelect">
                        <option value=""></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "base/dw/qry";
        $("#form-param-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-param-add').serialize());
            }
        }

        function dwTbChange(ele) {

            var cdDwTb = $(ele).val();
            $.ajax({
                type: "POST",
                url: "/md/med/fld/list",
                data: JSON.stringify({"cdTb":cdDwTb}),
                dataType: 'json',
                contentType: 'application/json;charset=UTF-8',
                success: function(res) {
                    var data = res.rows;
                    var fieldSelectHtml = "";
                    $.each(data,function (index,item) {
                        fieldSelectHtml += '<option value="'+item.idPubfld+'">'+item.naPubfld+'</option>';
                    });
                    $("#fieldSelect").html(fieldSelectHtml);
                }
            });
        }

        $("input[name='dtSysCre']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='dtSysModi']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>